package org.ruoyi.common.dhuman.backup;

import org.ruoyi.common.dhuman.utils.LocalSubtitleGenerator;

public class SubtitleGeneratorDemo {

	public static void main(String[] args) {
		try {
			// 模型文件路径 - 需要根据实际下载的模型路径修改
			String acousticModel = "D:\\workspace\\cmusphinx-zh-cn-5.2\\zh_cn.cd_cont_5000";
			String dictionary = "D:\\workspace\\cmusphinx-zh-cn-5.2\\zh_cn.dic";
			String languageModel = "D:\\workspace\\cmusphinx-zh-cn-5.2\\zh_cn.lm.bin";

			// 创建字幕生成器
			LocalSubtitleGenerator generator = new LocalSubtitleGenerator(
				acousticModel, dictionary, languageModel
			);

			// 尝试初始化对齐器
			try {
				generator.initialize();
				System.out.println("语音对齐器初始化成功");
			} catch (Exception e) {
				System.out.println("语音对齐器初始化失败，将使用时间估算方法: " + e.getMessage());
			}

			// 生成字幕
			//			String audioFile = "C:\\Users\\Admin\\Videos\\合并\\20251028.171029.586\\subPPT_0\\tts_1179119487945973760_1761290453.mp3";
			//			String textFile = "C:\\Users\\Admin\\Videos\\合并\\20251028.171029.586\\subPPT_0\\文案.txt";;
			//			String outputSrt = "C:\\Users\\Admin\\Videos\\合并\\20251028.171029.586\\subPPT_0\\文案.srt";

			String audioFile = "C:\\Users\\Admin\\Videos\\hanlu.mp3";
			String textFile = "C:\\Users\\Admin\\Videos\\hanlu.txt";;
			String outputSrt = "C:\\Users\\Admin\\Videos\\hanlu.srt";

			generator.generateSubtitles(audioFile, textFile, outputSrt);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}